\documentclass{ctexart}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{cite}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,chains}

\title{roots.c简介}

\author{周游 \\ 强基数学3200106105}

\date{2022/7/2}

\begin{document}

\maketitle

\section{简介}
roots.c可以计算一维多项式方程的求根。
本roots.c示例中为求解$x^2-5=0$的正根$x=\sqrt{5}=2.236068...$。\\
设置预期解的区间为[0,5]:\\
$$x\_lo = 0.0, x\_hi = 5.0$$
设置方程为$x^2-5=0$：\\
$$params = {1.0, 0.0, -5.0}$$
部分代码：
\begin{verbatim}
    double x_lo = 0.0, x_hi = 5.0;   //解的上下限
    gsl_function F;
    struct quadratic_params params = {1.0, 0.0, -5.0}; //x^2-5=0.
\end{verbatim}

\section{示例}
运行make后在bin下生成可执行文件roots，运行roots得到以下结果：
\begin{verbatim}
using brent method
 iter [    lower,     upper]      root        err  err(est)
    1 [1.0000000, 5.0000000] 1.0000000 -1.2360680 4.0000000
    2 [1.0000000, 3.0000000] 3.0000000 +0.7639320 2.0000000
    3 [2.0000000, 3.0000000] 2.0000000 -0.2360680 1.0000000
    4 [2.2000000, 3.0000000] 2.2000000 -0.0360680 0.8000000
    5 [2.2000000, 2.2366300] 2.2366300 +0.0005621 0.0366300
Converged:
    6 [2.2360634, 2.2366300] 2.2360634 -0.0000046 0.0005666
\end{verbatim}
故得$x^2-5=0$的正根$x=\sqrt{5}$约为2.236

\end{document}